package com.xuelang.pipeline.entry.resource;

import com.xuelang.pipeline.app.resource.ToolChainService;
import com.xuelang.pipeline.client.common.request.PageParam;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.common.result.PageRecord;
import com.xuelang.pipeline.client.resource.IToolChainService;
import com.xuelang.pipeline.client.resource.dto.ToolChainDTO;
import com.xuelang.pipeline.client.resource.dto.ToolChainQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 工具链服务web控制类
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
@Slf4j
@RestController
@RequestMapping("/tool-chain")
public class ToolChainController implements IToolChainService {

    @Autowired
    private ToolChainService toolChainService;

    @Override
    public ApiResult<PageRecord<ToolChainDTO>> pageToolChainList(PageParam<ToolChainQuery> dtoPageParam) {
        return ApiResult.success(toolChainService.pageList(dtoPageParam));
    }

    @Override
    public ApiResult<List<ToolChainDTO>> conditionalToolChainList(ToolChainQuery toolChainQuery) {
        return ApiResult.success(toolChainService.list(toolChainQuery));
    }


    @Override
    public ApiResult<Boolean> addToolChain(ToolChainDTO toolChainDTO) {
        return ApiResult.success(toolChainService.add(toolChainDTO));
    }

    @Override
    public ApiResult<Boolean> updateToolChain(ToolChainDTO toolChainDTO) {
        return ApiResult.success(toolChainService.update(toolChainDTO));
    }

    @Override
    public ApiResult<Boolean> deleteToolChain(String code) {
        return ApiResult.success(toolChainService.delete(code));
    }

    @Override
    public ApiResult<ToolChainDTO> queryToolChain(String code) {
        return ApiResult.success(toolChainService.query(code));
    }
}